<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<%@include file="/commons/etCommonHead.jsp"%>
</head>
<body>
  <div id="header">
      <div class="gohome radius20"><a href="<%=basePath%>ph/sys/index.do"><img src="<%=basePath%>et/images/icons/home.png" alt="" title="" /></a></div>
      <div class="gomenu radius20"><a href="<%=basePath%>ph/sys/ordered.do" onclick=""><img src="<%=basePath%>et/images/icons/about.png" alt="" title="" /></a></div>
  </div>
  <div class="swiper-container swiper-parent">
    <div class="swiper-wrapper">
    

      

     
<!--Page 3 content-->
      <div class="swiper-slide sliderbg">
      <div class="swiper-container swiper-nested3">
               <div class="swiper-wrapper">
                    <div class="swiper-slide">
                              <div class="slide-inner">
                                        <div class="pages_container ">
										
										<h3 class="page_title">我的本周课表</h3>
										
										<ul id="tabsmenu" class="tabsmenu">
                                            <li class="active"><a href="#tab1">全部课程</a></li>
                                            <li><a href="#tab2">未上课程</a></li>
                                            <li><a href="#tab3">已上课程</a></li>
                                        </ul>
                                        <div id="tab1" class="tabcontent">
												<ul class="posts" id="tab1_posts">
                                            
												</ul>
                                        </div>
                                        <div id="tab2" class="tabcontent">
												<ul class="posts" id="tab2_posts">
	                                            
												</ul>
                                        </div>
                                
                                        <div id="tab3" class="tabcontent">
												<ul class="posts" id="tab3_posts">
												</ul>
                                        </div>       
										
										
										
										
										
										
										
                                       
       
     <!--End of pages--> 

    </div>
   
  </div>
</body>
<%@include file="/commons/etCommonJs.jsp"%>
<script type="text/javascript">
$(document).ready(function(){
	ajaxDiv(false, '', '<%=basePath%>ph/classTable/myOrderClass.do','' , queryClassTableByDate2);
});

	
	
	function queryClassTableByDate2(data,divId){
		var classTableList = data["classTableList"];
		showClassTable(classTableList);
	}
	
	
	function showClassTable(classTableList){
		$("#tab1_posts").html("");
		$("#tab2_posts").html("");
		$("#tab3_posts").html("");
		for ( var i = 0; i < classTableList.length; i++) {
			var classTable = classTableList[i];
			if(classTable.id>0){
				var dateStr=classTable.classDate.toString();
       			dateStr =  dateStr.replace(/-/g,"/");
       			var day = new Date(Date.parse(dateStr));   //需要正则转换的则 此处为 ： var day = new Date(Date.parse(date.replace(/-/g, '/')));  
				 var today = new Array('Sun','Mon','Tue','The','Wed','Fri','Sat');  
				 var week = today[day.getDay()];
				 
       			
				var arr=new Array();
				//注split可以用字符或字符串分割
				var level = "";
				var levelType=classTable.levelType;
				var classLevel=classTable.classLevel;
				if(levelType=="all"){
					level = "all level";
				}else if(levelType=="equals"){
					arr=classLevel.split(',');
					level = "level"+arr[1];
				}else if(levelType=="above"){
					arr=classLevel.split(',');
					level = "above level"+arr[1];
				}else{
					arr=classLevel.split(',');
					level = "level"+arr[1]+"-"+arr[arr.length-2];
				}
				var str1='<li class="post" ><a id="tab1_'+classTable.id+'_a" href="javascript:cancelClass(\'tab1\','+classTable.id+')" class="post_more activep"></a>';
				var str2='<li class="post" ><a id="tab2_'+classTable.id+'_a" href="javascript:cancelClass(\'tab2\','+classTable.id+')" class="post_more activep"></a>';
				var str3='<li class="post" ><a id="tab3_'+classTable.id+'_a" href="javascript:void(0)" class="post_more"></a>';
				
				var	str='<div class="post_right_reveal">';
	                str+='<h5><a href="#" onclick="">课名：'+classTable.classInfoName+'；教师：'+classTable.classTeacherName+'；地点：'+classTable.classAddr+'；级别：'+level+'；限定人数：'+classTable.studentNum+'；</a></h5>';
	                str+='</div><div class="post_right_unreveal">';
	                str+='	<span id="span_'+classTable.id+'" class="post_comments">取消订课成功</span>';
	                str+='</div><div class="post_left">';
	                str+='   <span class="day">'+week+'</span>';
	           		str+='   <span class="month">'+classTable.classStartTime+'--'+classTable.classEndTime+'</span>';
                	str+=' <input type="hidden" id="startTime'+classTable.id+'" value="'+classTable.classDate+' '+classTable.classStartTime+'"></div></li>';
				
	            
	            var date1 = new Date(Date.parse((classTable.classDate+" "+classTable.classEndTime).replace(/-/g,"/"))); 
       			var date2 = new Date();    
	            if((date1-date2)>0){
       				$("#tab1_posts").append(str1+str);
       			}else{
       				$("#tab1_posts").append(str1+str);
       				$("#tab1_a_"+classTable.id).attr("href","javascript:void(0)"); 
       				$("#tab1_a_"+classTable.id).css("background","#e2e2e2 url('<%=basePath%>et/colors/blue/images/checked.png') no-repeat scroll center center");
       			//$("#a_"+classTable.id).css("width","5px");
       			
       			}
				
				
       			
       			if((date1-date2)>0){
       				$("#tab2_posts").append(str2+str);
       			}else{
       				$("#tab3_posts").append(str3+str);
       				$("#tab3_a_"+classTable.id).css("background","#e2e2e2 url('<%=basePath%>et/colors/blue/images/checked.png') no-repeat scroll center center");
       			
       			}
				
			}
		}
	}
	
	
	
	
	
	function cancelClass(tabId,id){
		var startTime=$("#startTime"+id).val();
		var date1 = new Date(Date.parse(startTime.replace(/-/g,"/"))); 
       	var date2 = new Date(); 
		if((date1-date2)/3600/1000 >2){
			ajaxDiv(false, tabId+"_"+id+"_a", '<%=basePath%>ph/classTable/cancelClass.do','{id:'+id+'}' , cancelClass2);
		}else{
			alert("对不起，必须提前两个小时才能取消课程！")
		}
	}
	function cancelClass2(data,divId){
		if(data["flag"]==0){
			$("#"+divId).toggleClass("activep").next().slideToggle("slow");
			var idInt = setInterval(function(){
				$("#"+divId).next().slideToggle("slow");
				$("#"+divId).parent().remove();
				
				clearInterval(idInt);
			},1000);
		}
	}
</script>
</html>